fix(core): silently skip GEMINI.md paths that are directories (EISDIR)#25662
fix(core): silently skip GEMINI.md paths that are directories (EISDIR)#25662martin-hsu-test wants to merge 2 commits intogoogle-gemini:mainfrom
Conversation
When a directory named GEMINI.md exists in the workspace tree, the memory discovery process previously logged a confusing 'Could not read GEMINI.md' warning because fs.readFile throws EISDIR on directories. Directories with that name are valid in some project structures and should simply be ignored. Detect EISDIR specifically in the readGeminiMdFiles catch block and skip silently with a debug log, while preserving the warning behaviour for genuinely unexpected read errors. Adds two tests: - a direct readGeminiMdFiles test asserting null content (no throw) when given a directory path - an end-to-end loadServerHierarchicalMemory test asserting empty memory when a GEMINI.md directory is present in the workspace Fixes google-gemini#16282 Supersedes google-gemini#22852 (closed due to test failures and inactivity); the production fix here uses the same NodeJS.ErrnoException type guard that gemini-code-assist suggested on that PR, with fresh tests written from scratch against the current code.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the memory discovery process incorrectly flagged directories named Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces graceful handling for cases where a directory exists at a path expected to be a GEMINI.md file. The readGeminiMdFiles function in packages/core now specifically catches EISDIR errors, logging a debug message instead of a warning to prevent user confusion. Additionally, new test cases have been added to memoryDiscovery.test.ts to verify that these directories are correctly ignored without throwing exceptions. I have no feedback to provide.
…directory The original issue (google-gemini#16282) describes two scenarios beyond 'just don't warn': directories named GEMINI.md should be 'ignored in favor of actual files', and the fix should 'handle symlinks more robustly'. Add two tests asserting these behaviours hold: - a higher-level real GEMINI.md still loads when a lower-level path of the same name is a directory - a symlink whose target is a directory is silently skipped exactly like a plain directory (skipped on Windows when symlink creation requires elevated privileges)
|
Pushed a follow-up commit (1236565) adding two tests that cover the broader contract from the issue:
All 46 |
Summary
When a directory named
GEMINI.mdexists anywhere in the workspace tree, memory discovery currently surfaces a confusingCould not read GEMINI.mdwarning becausefs.readFilethrowsEISDIRon directories. Directories with that name are valid in some project structures and should simply be ignored.This PR detects
EISDIRspecifically in thereadGeminiMdFilescatch block and skips silently with a debug log, while preserving the warning behaviour for genuinely unexpected read errors.Fixes #16282
Implementation
packages/core/src/utils/memoryDiscovery.ts— extend the existing catch block:The return value is unchanged (
{ filePath, content: null }) so downstream consumers continue to see the same shape.Tests
Two new tests in
memoryDiscovery.test.ts:readGeminiMdFilesreturns{ content: null }(without throwing) when given a directory pathloadServerHierarchicalMemoryreturns empty memory when aGEMINI.mddirectory exists in the workspaceTest results:
tsc --noEmitandeslintboth pass with zero output.Relationship to #22852
This supersedes #22852 (closed 2026-04-09 due to test failures and 23 days of inactivity). Credit to @shathwik30 for the original work; the production-code shape here uses the same
NodeJS.ErrnoExceptiontype guard that @gemini-code-assist suggested on that PR.What's different in this PR:
memoryDiscovery.tsand verified to pass locally before submissionreadGeminiMdFilesunit test (alongside the e2e test) to keep the failure surface narrow and easy to debug for future contributorsmemoryContent === '', which is the user-visible contract the issue actually cares about, rather than relying onfileCountsemantics that could shift